package stackmachine.command;

import stackmachine.IP;
import stackmachine.StackItem;

import java.util.LinkedList;

/**
 * Created with IntelliJ IDEA.
 * User: Kvest
 * Date: 29.07.13
 * Time: 21:08
 * To change this template use File | Settings | File Templates.
 */
public class ChrCommand extends Command {
    @Override
    public boolean commit(LinkedList<StackItem> stack, LinkedList<StackItem> out, IP ip) {
        StackItem<Integer> p = stack.pollLast();
        if (p == null) {
            return false;
        }

        stack.addLast(new StackItem<Character>((char)p.getValue().intValue()));
        ip.increment();
        return true;
    }
}
